<template>
	<view>
		<view>
			<uni-row>
				<uni-col :span="6">
					<image src="/static/myPlace/head_img.png" style="width: 150rpx; height: 150rpx;">
					</image>
				</uni-col>
				<uni-col :span="16" v-if="userId==null">
					<navigator url="../index/login.vue" hover-class="navigator-hover">
						<button type="default">登录/注册</button>
					</navigator>
				</uni-col>
				<uni-col :span="16" v-else>
					<view>
						<text style="line-height: 150rpx;" v-text="user.nickName">11111</text>
					</view>
				</uni-col>
			</uni-row>
			<uni-row style="text-align: center;">
				<uni-col :span="8">
					<b>
						<view>-</view>
					</b>
					<small>
						<view>等级</view>
					</small>
				</uni-col>
				<uni-col :span="8">
					<b>
						<view v-text="amount">-</view>
					</b>
					<small>
						<view>钱包</view>
					</small>
				</uni-col>
				<uni-col :span="8">
					<b>
						<view v-text="skillCount">-</view>
					</b>
					<small>
						<view>技能</view>
					</small>
				</uni-col>
			</uni-row>
			<view style="padding: 20rpx; margin-top: 40rpx;" >
				<view @click="toCenter()" >
					<uni-row>
						<uni-col :span="4">
							<image src="/static/myPlace/wd_icon_grzx.png" style="width: 60rpx; height: 60rpx;"></image>
						</uni-col>
						<uni-col :span="16">
							个人中心
						</uni-col>
					</uni-row>
				</view>
				<view @click="toWorkman()" >
					<uni-row>
						<uni-col :span="4">
							<image src="/static/myPlace/wd_icon_sfrz.png" style="width: 60rpx; height: 60rpx;"></image>
						</uni-col>
						<uni-col :span="16" >
							师傅入驻
						</uni-col>
					</uni-row>
				</view>
				<view @click="toWallet()" >
					<uni-row>
						<uni-col :span="4">
							<image src="/static/myPlace/wd_icon_wdqb.png" style="width: 60rpx; height: 60rpx;"></image>
						</uni-col>
						<uni-col :span="16">
							我的钱包
						</uni-col>
					</uni-row>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				user: {},
				amount: null,
				skillCount: null
			}
		},
		onLoad() {
			//加载用户信息
			uni.request({
				url: 'http://120.46.197.40:8080/api/user/getUserInfo',
				method: 'GET',
				data: {
					userId: this.userId
				},
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				success: (res) => {
					//console.log(res.data.data.nickName);
					this.user = res.data.data;
					//this.text = 'request success';
				}
			});
			//加载账户信息
			uni.request({
				url: 'http://120.46.197.40:8080/api/userAccount/getUserAccountInfo',
				method: 'GET',
				data: {
					userId: this.userId
				},
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				success: (res) => {
					//console.log(res.data.data.amount);
					this.amount = res.data.data.amount;
					//this.text = 'request success';
				}
			});
			//加载技能数量
			uni.request({
				url: 'http://120.46.197.40:8080/api/userAuthentication/getUserCategory',
				method: 'GET',
				data: {
					userId: this.userId
				},
				header: {
					'content-type': 'application/x-www-form-urlencoded'
				},
				success: (res) => {
					//console.log(res.data.data.amount);
					this.skillCount = res.data.data.categoryList.length;
					//this.text = 'request success';
				}
			});

		},
		methods: {
			// 跳转到个人中心
			toCenter(){
				uni.navigateTo({
					url:"/pages/home/userCenter"
				})
			},
			// 跳转到师傅入驻
			toWorkman(){
				uni.navigateTo({
					url:"/pages/home/workman"
				})
			},
			// 跳转到我的钱包
			toWallet(){
				uni.navigateTo({
					url:"/pages/home/wallet"
				})
			}
		}
	}
</script>

<style>

</style>
